<?php
/**
 * Contains the Event_Log_Handler class.
 * 
 * @package    event
 * @subpackage log
 * @author 	   Gerrit Jan van Ahee <gerrit.jan@yes2web.nl>
 * @copyright  2010-2011 Yes2web B.V.
 * @license    MIT License http://www.opensource.org/licenses/mit-license.php
 * @version    1.0.0
 * @link 	   www.yes2web.nl
 */
/**
 * Event_Log_Handler picks up on interesting {@link Event_Event}s and logs them.
 *
 * @package    event
 * @subpackage log
 * @author 	   Gerrit Jan van Ahee <gerrit.jan@yes2web.nl>
 * @copyright  2010-2011 Yes2web B.V.
 * @license    MIT License http://www.opensource.org/licenses/mit-license.php
 * @version    1.0.0
 * @link 	   www.yes2web.nl
 */
class Event_Log_Handler extends Event_Handler {
	/**
	 * @var Event_Log_Device
	 */
	protected $oLogger;
	
	/**
	 *
	 *
	 * @SuppressWarnings(PHPMD.LongVariable)
	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
	 */
	public function __construct(Event_Log_Device $oLogger, $sDispatcherClassName){
		$asDispatcher = func_get_args();
		$this->oLogger = array_shift($asDispatcher);
		call_user_func_array(array('parent', '__construct'), $asDispatcher);
	}
	/**
	 *
	 * @param Event_Log_Message $oMessage the message wrapper to log
	 * @return Event_Log_Handler $this instance (to support chaining)
	 */
	protected function log(Event_Log_Message $oMessage){
		$this->oLogger->add((string) $oMessage);
		return $this;
	}
}